package com.campus.mapper.Impl;

import com.campus.domain.Dto.CourseCreateDto;
import com.campus.mapper.CourseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.sql.Date;

@Repository
public class CourseMapperImpl implements CourseMapper {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    @Override
    public Integer addCourse(CourseCreateDto courseCreateDto) {
        String sql = "insert into t_course (course_name, created_time, status, activity_id, teacher_id, class_id) values (?,?,?,?,?,?)";

        Object[] args = new Object[]{
                courseCreateDto.getCourseName(),
                new Date(new java.util.Date().getTime()),
                "0",
                courseCreateDto.getActivityId(),
                courseCreateDto.getTeacherId(),
                courseCreateDto.getClassId()
        };

        return jdbcTemplate.update(sql,args);
    }
}
